﻿/**************************************************************************
创建时间:	2020/6/24
作	  者:	张存
邮 	  箱:	zhangcunliang@126.com

Copyright (c) zhcun.cn

描	述：
记	录：
***************************************************************************/
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using System.Net;
using ZhCun.WebUtils.Configs;

namespace ZhCun.WebUtils
{
    /// <summary>
    /// host操作类
    /// </summary>
    public class HostHelper
    {
        public static IWebHostBuilder CreateWebHostBuilder(string[] args)
        {
            return
            WebHost
                .CreateDefaultBuilder(args)
                .ConfigureKestrel((context, options) =>
                {
                    if (CommonConfig.THIS.HttpPort > 0)
                    {
                        options.Listen(IPAddress.Any, CommonConfig.THIS.HttpPort);
                    }
                    if (CommonConfig.THIS.HttpsPort > 0)
                    {
                        options.Listen(
                            IPAddress.Any,
                            CommonConfig.THIS.HttpsPort,
                            listenOptions =>
                            {
                                listenOptions.UseHttps(CommonConfig.THIS.SSLFileName, CommonConfig.THIS.SSLFilePassword);
                            });
                    }
                });
                //.UseStartup<Startup>();
        }
    }
}